package com.bjpowernode.dataservice.mapper;

import com.bjpowernode.api.model.FinanceAccount;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;

public interface FinanceAccountMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(FinanceAccount record);

    int insertSelective(FinanceAccount record);

    FinanceAccount selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(FinanceAccount record);

    int updateByPrimaryKey(FinanceAccount record);

    /**
     * 扣除账户资金
     * @param userId
     * @param investMoney
     * @return
     */
    int updateInvest(@Param("userId") Integer userId, @Param("investMoney") BigDecimal investMoney);

    /**
     * 查询用户资金
     * @param userId
     * @return
     */
    FinanceAccount selectByUserIdForUpdate(@Param("userId") Integer userId);

    /**
     * 更新资金账号
     * @param uid
     * @param bidMoney
     * @param incomeMoney
     * @return
     */
    int updateByIncomeBack(@Param("uid") Integer uid, @Param("bidMoney") BigDecimal bidMoney, @Param("incomeMoney") BigDecimal incomeMoney);

    /**
     * 给资金账号增加金额
     * @param uid
     * @param rechargeMoney
     * @return
     */
    int updateByRecharge(@Param("uid") Integer uid, @Param("rechargeMoney") BigDecimal rechargeMoney);
}